package models

import (
	"gorm.io/gorm"
)

type Press struct {
	gorm.Model
	Title string `gorm:"type:varchar(100)" json:"title"`
	Cate  string `gorm:"type:enum('科技新闻','体育新闻')" json:"cate"`
}

func (p *Press) Add() error {
	return DB.Create(&p).Error
}
func (p *Press) List() (press []Press, err error) {
	err = DB.Find(&press).Error
	return press, err
}
func (p *Press) Del(id int) error {
	err := DB.Delete(&p, id).Error
	return err
}
